package com.mjk.rest.system;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mjk.common.biz.BaseBiz;
import com.mjk.common.rest.BaseController;
import com.mjk.common.vo.ObjectRestResponse;
import com.mjk.common.vo.TableResponse;
import com.mjk.model.system.BaseGroup;
import com.mjk.model.system.BaseGroupType;
import com.mjk.service.system.BaseGroupService;
import com.mjk.service.system.BaseGroupTypeService;

import tk.mybatis.mapper.entity.Example;

@RestController
@RequestMapping("api/groupType")
public class BaseGroupTypeController extends BaseController<BaseGroupTypeService, BaseGroupType>{
	
	@RequestMapping(value = "/pageType", method = RequestMethod.GET)
	public TableResponse<Object> pageType(@RequestParam(defaultValue="10") int limit, 
			@RequestParam(defaultValue="1") int page, String name) {
		Example example = new Example(BaseGroupType.class);
		if(StringUtils.isNotBlank(name)){
			example.createCriteria().andLike("name", "%" + name + "%");
		}
		Page<Object> result = PageHelper.startPage(page, limit);
		baseBiz.selectByExample(example);
		return new TableResponse<Object>(result.getTotal(), result.getResult());
	}
	
}
